package WaiBao;

import java.util.Arrays;

public class YangXingRun {
    public static void main(String[] args) {
        String[] name= {"张明(班长)", "李华(副班长)", "小李(学习委员)", "李小龙(文艺委员)", "李文海", "李文宁", "徐宁宁", "旭之光", "张小青", "杨考考", "张晓", "李文龙",
                "李欢", "李道琼", "李思", "张静文", "张晓", "贺精明", "核桃", "锤子", "铆钉", "砖头", "房东", "戴雨桐", "林泽凯", "林浩东", "张终会", "张三丰",
                "张无忌", "杨鑫润(体育委员)"};//考生本人:杨鑫润(体育委员)
        int[] age = {22, 21,19,20,20, 19, 21,22,18, 22,19,19, 21, 19, 21,20, 21, 19, 20, 19, 19,21, 21, 21, 20, 23, 19,22,21, 21};//考生年龄：21岁

        double[] naunbao1 = {90, 86, 80, 71, 75, 79, 75, 80, 73, 84, 64, 82, 71, 79, 65, 78, 62, 90, 86, 88, 92, 91, 95, 88, 75, 74, 78, 74, 81, 96};
        double[] naunbao2 = {84, 75, 78, 83, 80, 71, 73, 69, 80, 74, 75, 70, 85, 74, 80, 75, 74, 79, 64, 68, 92, 71, 95, 85, 78, 85, 67, 85, 71, 96};
        double[] naunbao3 = {87, 74, 74, 83, 71, 61, 68, 80, 84, 60, 63, 80, 75, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 79, 84, 77, 71, 80, 96};


        double demo1;//代表每个学生的总分
        double demo2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            demo1 = naunbao1[i] + naunbao2[i] +naunbao3[i];
//            demo2 = ( demo1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +demo1);
//            System.out.println(name[i] + "的平均分为:" +demo2);
//        }


        double shenghua1 = 0,shenghua2 = 0;
        double[] weisheng = new double[30];
//        for (int i = 0; i < 30; i++) {
//            shenghua1 = naunbao1[i] + naunbao2[i] + naunbao3[i];
//            shenghua2= (shenghua1 * 1.0) / 3;
//            weisheng[i] = shenghua2;
//        }
//
//        for (int i = 0; i <weisheng.length - 1; i++) {
//            for (int j = 0; j < weisheng.length - i - 1; j++) {
//                if (weisheng[j] < weisheng [j + 1]) {
//                    double tep =weisheng[j];
//                    weisheng[j] =weisheng[j + 1];
//                    weisheng[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(weisheng[i]);
//        }



        double mainsha1 = 0,mainsha2 = 0,mainsha3 = 0;//计算每门课的平均分
        double meiyou1 = 0,meiyou2 = 0, meiyou3 = 0;//计算每门课标准差
        double zhijing1 = 0,zhijing2 = 0,zhijing3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < naunbao1.length; i++) {
            sum2+=naunbao1[i];
        }
        mainsha1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+mainsha1);
        double Sum = 0;
        for (int i = 0; i <naunbao2.length; i++) {
            Sum+=naunbao2[i];
        }
        mainsha2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+mainsha2);
        double sum = 0;
        for (int i = 0; i <naunbao3.length; i++) {
            sum+=naunbao3[i];
        }
        mainsha3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+ mainsha3);


//
        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < naunbao1.length; i++) {
            c1+= (naunbao1[i] - mainsha1)*(naunbao1[i] -mainsha1);
        }
        meiyou1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+meiyou1);

        for (int i = 0; i <naunbao2.length; i++) {
            c2+= (naunbao2[i] -mainsha2)*(naunbao2[i] - mainsha2);
        }
        meiyou2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+meiyou2);

        for (int i = 0; i < naunbao3.length; i++) {
            c3+= (naunbao3[i] -mainsha3)*(naunbao3[i] -mainsha3);
        }
        meiyou3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+meiyou3);
//////////
        Arrays.sort(naunbao1);
        Arrays.sort(naunbao2);
        Arrays.sort(naunbao3);
        zhijing1 =(naunbao1[14]+naunbao1[15])*1.0/2;
        zhijing2 =(naunbao2[14]+naunbao2[15])*1.0/2;
        zhijing3 =(naunbao3[14]+naunbao3[15])*1.0/2;
        System.out.println("生物化学的中位数为:"+zhijing1);
        System.out.println("微生物学的中位数为:"+zhijing2);
        System.out.println("人体组织解剖学的中位数为:"+zhijing3);
//




    }
}
